package com.jyh.userInfo.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;

import com.jyh.config.BaseAction;
import com.jyh.config.datasource.TargetDataSource;
import com.jyh.userInfo.entity.JyhPerson;

@Repository
public class PersonInfoDao extends BaseAction{
	@Autowired
	private JdbcTemplate jdbcTemplate;
	/**
	 * 获取用户个人信息
	 * @return
	 */

	@TargetDataSource(name = "user")
	public List<JyhPerson> getJyhManager() {
		String sql = "SELECT *  FROM jyh_person";
		List<JyhPerson> list = jdbcTemplate.query(sql, new RowMapper<JyhPerson>() {
			
			public JyhPerson mapRow(ResultSet rs, int index) throws SQLException {
				JyhPerson jp = new JyhPerson();
				jp.setID(rs.getInt("ID"));
				jp.setUserNumber(rs.getString("userNumber"));
				jp.setPhoneNumber(rs.getString("phoneNumber"));
				jp.setUserName(rs.getString("userName"));
				return jp;
			}
		});
		return list;
	}
}
